`include "../codigo/Writeback.v"

module test_Writeback ( );

    reg clock;

    reg [4:0] mem_wb_regdest;
    reg mem_wb_writereg;
    reg [31:0] mem_wb_wbvalue;

    wire wb_reg_en;
    wire [4:0] wb_reg_addr;
    wire [31:0] wb_reg_data;

    wire [31:0] wb_fw_wbvalue;
    wire wb_fw_writereg;

    // Instanciação do módulo.
    Writeback writeback(                         
        clock ,
        // Memory
        mem_wb_regdest ,
        mem_wb_writereg ,
        mem_wb_wbvalue ,
        // Registers
        wb_reg_en ,
        wb_reg_addr ,
        wb_reg_data ,
        // Forwarding
        wb_fw_wbvalue ,
        wb_fw_writereg ) ;


    initial begin

        #1 $display("");
        #1 $display("=========== Teste 1: Sinais para Registradores ===========");
        #1 $display("Resumo: Verifica os sinais repassados ao MC.");
        #1 $display("Entrada: mem_wb_regdest = 5b'10000\n\tmem_wb_writereg = 1'b1\n\tmem_wb_wbvalue = 32d'69");
        #1 $display("Saida esperada: wb_reg_en = 1\n\twb_reg_addr = 10000;\n\twb_reg_data = 69");
        #1 clock = 1'b0;
        #1 mem_wb_regdest = 5'b10000;
        #1 mem_wb_writereg = 1'b1;
        #1 mem_wb_wbvalue = 32'd69;
        #1 clock = 1'b1;
        #1 $display("Resultado: wb_reg_en = %b\n\twb_reg_addr = %b;\n\twb_reg_data = %d",writeback.wb_reg_en,writeback.wb_reg_addr,writeback.wb_reg_data); 
       
        #1 $display("====================================================");
        #1 $display("=========== Teste 2: Sinais para Forward ===========");
        #1 $display("Resumo: Verifica os sinais repassados ao Forward.");
        #1 $display("Entrada: mem_wb_regdest = 5b'10000\n\tmem_wb_writereg = 1'b1\n\tmem_wb_wbvalue = 32d'69");
        #1 $display("Saida esperada: wb_fw_wbvalue = 69\n\twb_fw_writereg = 1;");
        #1 clock = 1'b0;
        #1 mem_wb_regdest = 5'b10000;
        #1 mem_wb_writereg = 1'b1;
        #1 mem_wb_wbvalue = 32'd69;
        #1 clock = 1'b1;
        #1 $display("Resultado: wb_fw_wbvalue = %d\n\twb_fw_writereg = %b;",writeback.wb_fw_wbvalue,writeback.wb_fw_writereg); 
        #1 $display("");

    end
endmodule

